home *** CD-ROM | disk | FTP | other *** search
- ───────────────────────────────────────────────────────────────────────────────
-
- HSC2H V1.0 and how to use HSCOBJ.OBJ in your C/C++ programs
-
- ───────────────────────────────────────────────────────────────────────────────
- -Dox By Timecop
-
- 1. Introduction.
- ~~~~~~~~~~~~
- One day I decided to write an intro in C and insert some music into it using
- Chiken's famous HSCOBJ.OBJ. I needed 2 things: an HSC2H converter and a
- working example of how to use HSCOBJ.OBJ in C. Since I didn't have either
- of them I had to write both of them. And then I said: "What the hell, I'll
- release both things!"
-
- 2. HSC2H converter.
- ~~~~~~~~~~~~~~~
- HSC2H is a nice simple utility that converts HSC binary music files to
- include in your C/C++ programs. It took me about 2 days to write it so I
- think that it's not necessary to release the source because there is nothing
- super-difficult in it.
-
- 3. A Working example.
- ~~~~~~~~~~~~~~~~~
- Now here it took me a while to figure out what goes where. Therefore I
- said to myself: "What the hell, I'll release the source!"
- Here you go:
-
- Name the file HSCTEST.C (extension should be .C)
-
- ----cut here----
- //////////////////////////////////////////////////////////////////////////////
- // Description : HSCOBJ.OBJ C/C++ Usage example //
- // Revision : 1 //
- // Compile : Borland C++ v3.1+ //
- // Author : Timecop [PWA] //
- // Creation : 07-02-95 //
- // Last update : 07-02-95 //
- //////////////////////////////////////////////////////////////////////////////
-
- #include <conio.h>
- #include <dos.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include "music.h" // song converted with HSC2H
-
- void far HSCPLAYER(void);
- unsigned int segment,offsett;
- int use_adlib;
-
- void main()
- {
- asm xor ax,ax // Detect adlib
- asm xor bx,bx
- asm xor cx,cx
- asm xor dx,dx
- asm mov ah,0x4
- HSCPLAYER();
- asm jc error
-
- use_adlib=1;
- goto noerror;
-
-
- error:;
- printf("Error! Unable to detect adlib on this system!\n");
- use_adlib=0;
-
-
- noerror:;
- printf("Adlib detected.\n");
- asm mov cx,0xffff
- loopje:;
- asm loop loopje
-
-
- segment=FP_SEG(music); // get segment
- offsett=FP_OFF(music); // get offset
-
-
- if( !use_adlib ) exit(0);
- asm mov ax,segment
- asm mov es,ax
- asm mov ax,offsett
- asm mov si,ax
- asm xor ax,ax
- asm xor bx,bx
- asm xor cx,cx
- asm xor dx,dx
- asm mov ah,0x0
- asm mov bh,0x0
- asm mov bl,0x0 // Function 0 : Start Playing
-
- HSCPLAYER();
- printf("Now playing. Press any key to quit");
-
- while ( !kbhit() );
-
- asm xor ax,ax
- asm xor bx,bx
- asm xor cx,cx
- asm xor dx,dx
- asm mov ah,0x3 // Function 3 : Fade Playing
- HSCPLAYER();
- delay(4000);
-
- asm xor ax,ax
- asm xor bx,bx
- asm xor cx,cx
- asm xor dx,dx
- asm mov ah,0x2 // Function 2 : Stop Playing
- HSCPLAYER(); // Also unloads the song from memory
-
- printf("\n\n");
- }
-
- //////////////////////////////////////////////////////////////////////////////
- // End Of File. //
- //////////////////////////////////////////////////////////////////////////////
- ----cut here----
-
- If you compile and link it right now, you will get a link error:
- "Undefined symbol _HSCPLAYER() in module HSCTEST.C"
- The only way that I found to fix that is to create a *project*. The only
- things that you have to add to it are: HSCTEST.C and HSCOBJ.OBJ. Now if
- you try to compile HSCTEST.C from project you shouldn't get any warning or
- error messages.
-
- 4. Last words.
- ~~~~~~~~~~
- If you'll ever use the above example, I want you to give me a little greet
- somewhere. Hey didn't cost you anything!
-
-
- END OF DOX
-